
package com.hertz.iris;

import java.io.IOException;

import javax.inject.Inject;

import android.app.Activity;
import android.content.Context;

import com.hertz.iris.authenticator.OpenIdTokenProvider;
import com.hertz.iris.core.IrisService;
import com.hertz.iris.core.UserAgentProvider;

/**
 * Provider for a {@link com.hertz.IrisService.core.BootstrapService} instance
 */
public class IrisServiceProvider {

    @Inject OpenIdTokenProvider openIdTokenProvider;
    @Inject UserAgentProvider userAgentProvider;
    private  String authkey = "";
    private String authType = "";
    private IrisService instance;
    private IrisService instance2;
    /**
     * Get service for configured key provider
     * <p>
     * This method gets an auth key and so it blocks and shouldn't be called on the main thread.
     *
     * @return bootstrap service
     * @throws IOException
     */
    public IrisService getService(Activity activity) {
//        return new BootstrapService(keyProvider.getAuthKey(activity), userAgentProvider);
    	if(instance == null){
    		instance = new IrisService(openIdTokenProvider.getOpenIdToken(activity), userAgentProvider);
    	}
    	return instance;
    }
    
    public IrisService getService(Context context){
//      return new BootstrapService(keyProvider.getAuthKey(activity), userAgentProvider);
	  	if(instance2 == null){
	  		instance2 = new IrisService(openIdTokenProvider.getOpenIdToken(context), userAgentProvider);
	  	}
	  	return instance2;
  }
//	public String getAuthkey() {
//		return authkey;
//	}
//	public void setAuthkey(String authkey) {
//		this.authkey = authkey;
//	}
//	public String getAuthType() {
//		return authType;
//	}
//	public void setAuthType(String authType) {
//		this.authType = authType;
//	}
}
